package com.travel.model.entity.payment;

import com.travel.model.entity.auth.User;
import com.travel.model.entity.service.Booking;
import com.travel.model.enums.PaymentMethod;
import com.travel.model.enums.PaymentStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.*;
import lombok.Data;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
@Entity
@Table(name = "payments")
@EntityListeners(AuditingEntityListener.class)
@Schema(description = "支付实体")
public class Payment {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Schema(description = "支付ID")
    private Long id;

    @Schema(description = "支付订单号")
    private String paymentNo;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    @Schema(description = "支付用户")
    private User user;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "booking_id")
    @Schema(description = "关联预订")
    private Booking booking;

    @Schema(description = "支付金额")
    private BigDecimal amount;

    @Schema(description = "支付状态")
    @Enumerated(EnumType.STRING)
    private PaymentStatus status;

    @Schema(description = "支付方式")
    @Enumerated(EnumType.STRING)
    private PaymentMethod paymentMethod;

    @CreatedDate
    @Schema(description = "创建时间")
    private LocalDateTime createdTime;

    @LastModifiedDate
    @Schema(description = "更新时间")
    private LocalDateTime updateTime;
} 